package com.qf.mapper;/*
 *保护你的大熊
 *2021/11/9
 *21:09
 */

import com.github.pagehelper.PageInfo;
import com.qf.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    /**
     * 根据用户id查询用户对象返回
     * @param id
     * @return
     */
    @Select("select * from t_users where id=#{id}")
    public User findUserById(@Param("id") Integer id);

    @Select("select * from t_users")
    public List<User> findUserAll();

    @Options(useGeneratedKeys = true , keyProperty = "id") // 自增key，主键为id
    @Insert("insert into t_users (name,password,sex,birthday,registTime) " +
            " values(#{user.userName},#{user.password},#{user.sex},#{user.birthday},#{user.registTime})")
    public void insertUser(@Param("user") User user);

    public void updateUser(User user);

    @Delete("delete from t_users where id=#{id}")
    public void deleteUser(@Param("id") Integer id);

    public List<User> findUserByName(String name);

    public List<User> findUserAndDesc();

    public List<User> findUserAndOrder();

    public List<User> findUserAndOrderAndProduct();

    public List<User> findUserByNameAndSex(User user);

    public List<User> findUserByIds(@Param("ids") List<Integer> ids);

    public List<User> findUserByNameAndSex2(@Param("user") User user);

    /**
     * 分页查询
     * @return
     */
    public List<User> findUserByPage();

}
